<template>
	<view class="page_box">
		<view class="content_box">
			<scroll-view scroll-y="true" @scrolltolower="loadMore" class="scroll-box">
				<view class="card" v-for="(item,index) in depotList" :key="index">
					<view class="" style="padding: 30rpx;">
						<view class="flex">
							<view class="left">查询日期：</view>
							<view class="right">2024-02-05 16:48:25</view>
						</view>
						<view class="flex mar15">
							<view class="left">防伪码：</view>
							<view class="right">564545645645</view>
						</view>
						<view class="flex mar15">
							<view class="left">查询结果：</view>
							<view class="right" style="color: #07BF2B;">官方正品，放心使用</view>
						</view>
						<view class="flex mar15">
							<view class="left">产品类别：</view>
							<view class="right">铣削刀具</view>
						</view>
						<view class="flex mar15" style="align-items: flex-start;">
							<view class="left">产品名称：</view>
							<view class="right" style="flex: 1;">L•K-5060-球刀L•K-5060-球刀L•K-5060-球刀</view>
						</view>
						<view class="flex mar15">
							<view class="left">规格型号：</view>
							<view class="right" style="flex: 1;">-</view>
						</view>
						<view class="flex mar15">
							<view class="left">出库时间：</view>
							<view class="right" style="flex: 1;">2024-02-05 16:48:25</view>
						</view>
						<view class="flex mar15">
							<view class="left">备注：</view>
							<view class="right" style="flex: 1;">-</view>
						</view>
					</view>
				</view>
				<!-- 缺省页 -->
				<shopro-empty
					v-if="isEmpty"
					:image="$IMG_URL + '/imgs/empty/empty_goods.png'"
					tipText="暂无查询记录"
					btnText="去首页"
					@click="$Router.pushTab('/pages/index/index')"
				></shopro-empty>
				<!-- 更多 -->
				<u-loadmore v-show="!isEmpty" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isEmpty: false, //无数据
				depotList: [],
				loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
				total: 0,// 总页数
				pageSize: 10,// 每页条数
				currentPage: 1, // 当前页数
				lastPage: 1 // 最后一页
			}
		},
		onLoad() {
			this.getDepotLog();
		},
		methods: {
			getDepotLog(){
				let that = this;
				let list = [];
				that.loadStatus = 'loading';
				that.$http('user.depotLog', {
					page: that.currentPage
				}).then(res => {
					if (res.code === 1) {
						list = res.data.list;
						list.map(item => {
							that.$set(item, 'checked', false);
						});
						that.depotList = [...that.depotList, ...list];
						that.isEmpty = !that.depotList.length;
						that.total = that.depotList.length;
						that.lastPage = Math.ceil(that.total / that.pageSize); // 计算总页数
						that.loadStatus = that.currentPage < that.lastPage ? 'loadmore' : 'nomore';
					}
				});
			},
			// 加载更多
			loadMore() {
				if (this.currentPage < this.lastPage) {
					this.currentPage += 1;
					this.getDepotLog();
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.left {
		font-weight: 400;
		font-size: 28rpx;
		color: #21201E;
		opacity: 0.6;
		width: 138rpx;
	}

	.right {
		font-weight: 400;
		font-size: 28rpx;
		color: #21201E;
		padding-left: 20rpx;
	}

	.flex {
		display: flex;
		align-items: center;
	}

	.mar15 {
		margin-top: 30rpx;
	}
</style>